<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>miniYUI.connection.asyncRequest</title>
<link type="text/css" rel="stylesheet" href="demo.css" />
<style type="text/css">
#out{width:400px;height:80px;}
</style>
</head>

<body>
<h1>Example of ajax method asyncRequest</h1>
<h2>API</h2>
<p>
    <dl>
        <dt>miniYUI.connection.<strong>asyncRequest</strong>(String method, String uri, Object callback, String data)</dt>
        <dd><em>method</em>: 'GET' or 'POST'</dd>
        <dd><em>uri</em>: request url like '../service.php'</dd>
        <dd><em>callback</em>: object parameter, see the example in this page's source code.</dd>
        <dd><em>data</em>: the key and value string will be sent to server, like 'a=1&b=2&c=3'</dd>
    </dl>
</p>
<h3>Sample:</h3>
<form action="?" method="post">
    <textarea id="out"></textarea><br/>
    <input type="button" value="get" onclick="fnGet()" />
    <input type="button" value="post" onclick="fnPost()" />
</form>
<script type="text/javascript" src="../trunk/miniyui-min.js"></script>
<script type="text/javascript">
    var YUI = miniYUI,
        YUC = YUI.connection;
    var out = document.getElementById('out'),
        oCallback = {
            async: false,   //no async
            cache: false,
            success: function(o) {out.value += o.responseText;},
            failure: function(o) {out.value += o.responseText;}
        },
        uri = 'service.php';

    var fnGet = function() {
        YUC.asyncRequest('get', uri, oCallback, 'para1=getTest&para2=fromminiYUI');
        out.value += 'do something here after no async ajax get..\n';
    };

    var fnPost = function() {
        YUC.asyncRequest('post', uri, oCallback, 'para1=postTest&para2=fromminiYUI');
        out.value += 'do something here after no async ajax post..\n';
    };
</script>
</body>
</html>
